package leetcode.秋招.虾皮;

/**
 * @author ：zsy
 * @date ：Created 2021/10/11 19:45
 * @description：
 */
import org.junit.Test;

import java.util.*;




public class Solution {
    /**
     * Note: 类名、方法名、参数名已经指定，请勿修改
     *
     *
     *
     * @param src string字符串 输入字符串
     * @param match string字符串 查找字符串
     * @param replace string字符串 替换字符串
     * @return string字符串
     */
    public String FindAndReplace(String src, String match, String replace) {
        // write code here
        if (src == null || "".equals(src)) return "";
        if (match == null || "".equals(match)) return src;
        if (src.indexOf(match) == -1) return src;
        if (src.equals(match)) return replace;
        int pos = 0;
        int findPos;
        while ((findPos = src.indexOf(match, pos)) != -1) {
            src = src.substring(0, findPos) + replace + src.substring(findPos + match.length());
            findPos += replace.length();
        }
        return src;
    }
}


